<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page import="zhcms.admin.*" %> 
<%@ page import="zhcms.framework.*" %> 
<%@ include file="include/adminhead.jsp" %>
<%
request.setCharacterEncoding("utf-8");
String action=request.getParameter("atcion");
GyUserLoginValidate gycheck=new GyUserLoginValidate();
int ischeck=gycheck.UserLoginValidate(request, response);
if(ischeck==0)
{
		try{
			out.println("<script language='javascript'>alert('对不起！，您还没有登陆');location.href=\"index.jsp\";</script>");
		}
		catch(Exception e){
			e.printStackTrace();
		}
} 

%>
<TABLE width="100%" border=0 align="center" cellPadding=0 cellSpacing=0 class=sortbutton>
	<tr> 
	    <th width="100%" height="22" valign="middle"><a href="?">管理首页</a> | <a href="?atcion=add">新增</a>  </th>
	</tr>
</table>
<br>
<% 
if(action==null || action.length()<=0  || action.equals("main"))
{
String page1=request.getParameter("p");
int pageb;    //存储当前页码
if(page1==null)
   pageb=1;
else 
   pageb=Integer.parseInt(page1);
  
GyColumn gyf=new GyColumn();

int countnum=gyf.listcount();
%>
<table width="98%" border="0" cellpadding="0" cellspacing="0" align="center" class="TableBorder">
  <tr valign="middle" align="center" height="22"> 
    <th class=sort width="50%">栏目名称(ID)</th>
    <th class=sort>文章数</th>
    <th class=sort width="20%">操作</th>
  </tr>
<%
if(countnum>0)
{
String lybpages="";
ArrayList<HashMap<String, String>> gytInFor;
gytInFor=new ArrayList<HashMap<String, String>>();
gytInFor=gyf.getAllList(pageb);
lybpages=gyf.getPageStr();
for(int i=0;i<gytInFor.size();i++)
{
	Map<String,String> iAdmininfo=new HashMap<String,String>();
	iAdmininfo =gytInFor.get(i);
	
	String bname="";
	if(iAdmininfo.get("ColumnType")==null || iAdmininfo.get("ColumnType").length()<=0 || iAdmininfo.get("ColumnType").equals("0"))
	{
		bname="";
	}
	else
	{
		bname="(专题)";
	}
	
	int Level=0;
	Level=(iAdmininfo.get("ColumnCode").length()/4-1)*4;
 %>
  <tr valign="middle" bgcolor="#FFFFFF" align="center" height="22"> 
    <td align="left">&nbsp;
 <%
if(iAdmininfo.get("ColumnCode").length()>4)
 {
 	out.println("├");
 }

for(int j=0;j<Level;j++)
{
	out.println("-");
}
  %>
    <%=iAdmininfo.get("Name")%>(<%=iAdmininfo.get("Id")%>)
    </td>
    <td align="left">&nbsp;<%=iAdmininfo.get("CountNum")%></td>
    <td><a href="?atcion=add&postid=<%=iAdmininfo.get("Id")%>">编辑</a> | <a href="/zhcms!admin!GyProvince(del).do?postid=<%=iAdmininfo.get("Id")%>" onclick="{if(confirm('确定删除吗?')){return true;}return false;}">删除</a></td>
  </tr>
<%
}
 %>
  <tr valign="middle" bgcolor="#FFFFFF" align="right">
	<td colspan="6" height="22">&nbsp;<%=lybpages%></td>
  </tr>
 <%
 }
 else
 {
 %> <tr valign="middle" bgcolor="#FFFFFF">
	<td colspan="6" height="22">&nbsp;暂时没有任何信息！</td>
  </tr>
 <%
 } 
 %>
</table>
<%
}
else if(action.equals("add")) 
{

String postid=request.getParameter("postid");
//out.println(" gggggggggggg");
String Name="";
String ColumnCode="";
String ColumnType="";
String IsColumn="";
String ColumnInfo="";

if(postid==null || postid.length()<=0)
{
	
}
else
{
	GyColumn gyfk=new GyColumn();
	ArrayList<HashMap<String, String>> gytFkOne;
	gytFkOne=new ArrayList<HashMap<String, String>>();
	gytFkOne=gyfk.getOneList(postid);
	if(gytFkOne.size()>0)
	{
		Map<String,String> iiFriendLinkinfo=new HashMap<String,String>();
		iiFriendLinkinfo=gytFkOne.get(0);
		Name=iiFriendLinkinfo.get("Name");
		ColumnCode=iiFriendLinkinfo.get("ColumnCode");
		ColumnType=iiFriendLinkinfo.get("ColumnType");
		IsColumn=iiFriendLinkinfo.get("IsColumn");
		ColumnInfo=iiFriendLinkinfo.get("ColumnInfo");
	}
	
}

%>
<script>
function change(obj,i) {
    he=parseInt(obj.style.height);
    if (he>=80&&he<=400)
    obj.style.height=he+i+'px';
    else
    obj.style.height='80px';
}
</script>
<table width="85%" border="0" cellspacing="0" cellpadding="0"  align=center>
<form action ="/zhcms!admin!GyColumn(save).do?postid=<%=postid%>" method=post id=form1 name=form1>
    <tr> 
      <td height=25 colspan=2><div align="center"><B>编辑栏目</b></div></td>
    </tr>
    <tr> 
      <td width="40%" align=center>栏目名称</td>
      <td width="60%"><input type="text" name="Name" size="35" value="<%=Name%>"></td>
    </tr>
    <tr> 
      <td width="40%" align=center>所属分类</td>
      <td width="60%"><select name=ColumnCode>
      <option value=>根栏目</option>
      			<%
      			GyColumn gyc=new GyColumn();
      			ArrayList<HashMap<String, String>> gytFkOne;
							gytFkOne=new ArrayList<HashMap<String, String>>();
      			
      			gytFkOne=gyc.getAllList();
      			for(int i=0;i<gytFkOne.size();i++)
			      			{
			      		Map<String,String> iiColumninfo=new HashMap<String,String>();
			      		iiColumninfo=gytFkOne.get(i);
			      		int Level=0;
			      		Level=(iiColumninfo.get("ColumnCode").length()/4-1)*3;
			      		out.println("<option value="+iiColumninfo.get("ColumnCode"));
			      		if(!ColumnCode.equals(""))
									{
										if(ColumnCode.substring((ColumnCode.length()-4)).equals(iiColumninfo.get("ColumnCode")))
										{
											out.println(" selected");
										}
										
									}	      		
			      		out.println(">");
			      		
			      		if(iiColumninfo.get("ColumnCode").length()>4)
									 {
									 	out.println("├");
									 }
									
									for(int j=0;j<Level;j++)
									{
										out.println("-");
									}
									out.println(iiColumninfo.get("Name")+"</option>");
			      			}
      			 %>
        </select></td>
    </tr>
    <tr> 
      <td width="40%" align=center>栏目简介</td>
      <td width="60%"><textarea name="ColumnInfo" cols="30" rows="3" wrap="VIRTUAL"><%=ColumnInfo%></textarea><br>&nbsp;<a href="javascript:change(document.all.info,-20)"><img src="images/minus.gif" border=0 title="缩小文本框"></a>&nbsp;&nbsp;<a href="javascript:change(document.all.info,20)"><img src="images/plus.gif" border=0 title="放大文本框"></a></td>
    </tr>
    <tr> 
      <td width="40%" align=center>栏目类型</td>
      <td width="60%">&nbsp;<select name=ColumnType><option value="0" <%if(ColumnType.equals("0")){ out.println("checked");} %>>正常</option><option value="1" <%if(ColumnType.equals("1")){ out.println("checked");} %>>专题</option></select></td>
    </tr>
    <tr bgcolor="#FFFFFF" valign="middle"> 
      <td width="20%" align="center">所属</td>
      <td align="left">&nbsp;
						<select name=IsColumn>
        		<option value="0" <%
        						if(IsColumn.equals("0"))
        									{
        										out.println(" selected ");
        									}
        		 %>>
        		 系统</option>
        		 <option value="1" <%
        						if(IsColumn.equals("1"))
        									{
        										out.println(" selected ");
        									}
        		 %>>
        		 栏目</option>
        </select>

				</td>
    </tr>
    <tr bgcolor="f7fbff">
      <td colspan="2" height=25 align=center><input type="submit" name="Submit" value="确定">&nbsp;&nbsp;<input type="reset" name="Submit2" value="重置"></td>
    </tr>
</form>
</table>
<%
}
%>
<%@ include file="include/adminfoot.jsp" %>

